import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../components/Home.vue'
import Users from '../components/system/Users.vue'
import Welcome from '../components/Welcome.vue'
import Roles from '../components/system/Roles.vue'
import Alarm from '../components/news/Alarm.vue'
import Urge from '../components/news/Urge.vue'
import Approval from '../components/news/Approval.vue'
import Log from '../components/news/Log.vue'
import Login from '../components/system/Login.vue'
import ProductStocks from '../components/product/ProductStocks'
import InStocks1 from '../components/product/InStocks1'
import OutStocks1 from '../components/product/OutStocks1'
import Address from '../components/product/Address'
import Area from '../components/product/Area'
import Inspection from '../components/inspect/Inspection'
import Report from '../components/inspect/Report'
import DefectManagement from '../components/inspect/DefectManagement'
import Issued from '../components/scrapped/Issued'
import Approve from '../components/scrapped/Approve'
import MaterialScrap from '../components/scrapped/MaterialScrap'
import AddStocks from "../components/basic/AddStocks";
import ContriBution from "../components/basic/ContriBution";
import ProductCategorys from "../components/basic/ProductCategorys";
import PublishStocks from "../components/basic/PublishStocks";
import Suppliers from "../components/basic/Suppliers";

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    redirect: '/welcome',
    children: [
      { path: '/welcome', name: 'Welcome', component: Welcome },
      { path: '/users', name: 'Users', component: Users },
      { path: '/roles', name: 'Roles', component: Roles },
      { path: '/alarm', name: 'Alarm', component: Alarm },
      { path: '/urge', name: 'Urge', component: Urge },
      { path: '/approval', name: 'Approval', component: Approval },
      { path: '/log', name: 'Log', component: Log },
      // Dyy
      { path: '/productStocks', name: 'ProductStocks', component: ProductStocks },
      { path: '/inStocks1', name: 'InStocks1', component: InStocks1 },
      { path: '/address', name: 'Address', component: Address },
      { path: '/area', name: 'Area', component: Area },
      { path: '/outStocks1', name: 'InStocks1', component: OutStocks1 },
      // Lhw
      { path: '/inspection', name: 'Inspection', component: Inspection },
      { path: '/report', name: 'Report', component: Report },
      { path: '/defmang', name: 'DefectManagement', component: DefectManagement },
      { path: '/issued', name: 'Issued', component: Issued },
      { path: '/approve', name: 'Approve', component: Approve },
      { path: '/materscp', name: 'MaterialScrap', component: MaterialScrap },
      // guodan
      {path: '/addStocks', name: 'AddStocks', component: AddStocks},
      {path: '/contribution', name: 'ContriBution', component: ContriBution},
      {path: '/productCategorys', name: 'ProductCategorys', component: ProductCategorys},
      {path: '/PublishStocks', name: 'PublishStocks', component: PublishStocks},
      {path: '/suppliers', name: 'Suppliers', component: Suppliers}
    ]
  }
]
// 解决重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  routes
})

export default router
